/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package fr.cggveritas.crewintranet.jms.entities;

import java.io.Serializable;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author Alassane
 */
@Entity
@Table(name = "users")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Users.findAll", query = "SELECT u FROM Users u"),
    @NamedQuery(name = "Users.findById", query = "SELECT u FROM Users u WHERE u.id = :id"),
    @NamedQuery(name = "Users.findByAvatarId", query = "SELECT u FROM Users u WHERE u.avatarId = :avatarId"),
    @NamedQuery(name = "Users.findByLogin", query = "SELECT u FROM Users u WHERE u.login = :login"),
    @NamedQuery(name = "Users.findByPass", query = "SELECT u FROM Users u WHERE u.pass = :pass"),
    @NamedQuery(name = "Users.findByNom", query = "SELECT u FROM Users u WHERE u.nom = :nom"),
    @NamedQuery(name = "Users.findByPrenom", query = "SELECT u FROM Users u WHERE u.prenom = :prenom"),
    @NamedQuery(name = "Users.findByRulesId", query = "SELECT u FROM Users u WHERE u.rulesId = :rulesId"),
    @NamedQuery(name = "Users.findByMissionId", query = "SELECT u FROM Users u WHERE u.missionId = :missionId"),
    @NamedQuery(name = "Users.findByFavoryMonnaie", query = "SELECT u FROM Users u WHERE u.favoryMonnaie = :favoryMonnaie"),
    @NamedQuery(name = "Users.findByStatue", query = "SELECT u FROM Users u WHERE u.statue = :statue")})
public class Users implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "id")
    private Integer id;
    @Basic(optional = false)
    @Column(name = "avatar_id")
    private int avatarId;
    @Basic(optional = false)
    @Column(name = "login")
    private String login;
    @Basic(optional = false)
    @Column(name = "pass")
    private String pass;
    @Basic(optional = false)
    @Column(name = "nom")
    private String nom;
    @Basic(optional = false)
    @Column(name = "prenom")
    private String prenom;
    @Column(name = "rules_id")
    private Integer rulesId;
    @Column(name = "mission_id")
    private Integer missionId;
    @Column(name = "favory_monnaie")
    private String favoryMonnaie;
    @Basic(optional = false)
    @Column(name = "statue")
    private short statue;
    @JoinColumn(name = "right_id", referencedColumnName = "id")
    @ManyToOne(optional = false, fetch = FetchType.EAGER)
    private Right rightId;

    public Users() {
    }

    public Users(Integer id) {
        this.id = id;
    }

    public Users(Integer id, int avatarId, String login, String pass, String nom, String prenom, short statue) {
        this.id = id;
        this.avatarId = avatarId;
        this.login = login;
        this.pass = pass;
        this.nom = nom;
        this.prenom = prenom;
        this.statue = statue;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public int getAvatarId() {
        return avatarId;
    }

    public void setAvatarId(int avatarId) {
        this.avatarId = avatarId;
    }

    public String getLogin() {
        return login;
    }

    public void setLogin(String login) {
        this.login = login;
    }

    public String getPass() {
        return pass;
    }

    public void setPass(String pass) {
        this.pass = pass;
    }

    public String getNom() {
        return nom;
    }

    public void setNom(String nom) {
        this.nom = nom;
    }

    public String getPrenom() {
        return prenom;
    }

    public void setPrenom(String prenom) {
        this.prenom = prenom;
    }

    public Integer getRulesId() {
        return rulesId;
    }

    public void setRulesId(Integer rulesId) {
        this.rulesId = rulesId;
    }

    public Integer getMissionId() {
        return missionId;
    }

    public void setMissionId(Integer missionId) {
        this.missionId = missionId;
    }

    public String getFavoryMonnaie() {
        return favoryMonnaie;
    }

    public void setFavoryMonnaie(String favoryMonnaie) {
        this.favoryMonnaie = favoryMonnaie;
    }

    public short getStatue() {
        return statue;
    }

    public void setStatue(short statue) {
        this.statue = statue;
    }
    public boolean isUsersActive(){
        if(this.statue == 1){
            return true;
        }
        return false;
    }
    public Right getRightId() {
        return rightId;
    }

    public void setRightId(Right rightId) {
        this.rightId = rightId;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Users)) {
            return false;
        }
        Users other = (Users) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "fr.cggveritas.crewintranet.jms.entities.Users[ id=" + id + " ]";
    }
    
}
